package com.bookmanger.server.mapper;

import com.bookmanger.pojo.DTO.CheckInfoDTO;
import com.bookmanger.pojo.Entity.AdminEntity;
import com.bookmanger.pojo.Entity.Reader;
import com.bookmanger.pojo.Entity.UserEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    @Select("select * from reader where reader_number = #{username} and password = #{md5String} and status=1")
    Reader findByUsernameAndPassword4Reader(String username, String md5String);


    @Select("select * from manager where account = #{username} and password = #{md5String}")
    AdminEntity findByUsernameAndPassword4Admin(String username, String md5String);

    @Select("SELECT * FROM reader WHERE ${type}=#{info}")
    String checkInfo(CheckInfoDTO checkInfoDTO);

    @Insert("insert into reader(reader_number,password,name,department,major,grade,phone_number,email,gender,status,apply_date) values(#{readerNumber},#{password},#{name},#{department},#{major},#{grade},#{phoneNumber},#{email},#{gender},#{status},#{applyDate})")
    boolean registerByEmail(Reader reader);
}
